package com.itheima.utils;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//统一响应结果
@NoArgsConstructor //无参构造方法
@AllArgsConstructor //全参构造方法
@Data
public class Wangeditor<T> {
    private Integer errno;//业务状态码  0-成功  1-失败
    private String message;//提示信息
    private T data;//响应数据

    //快速返回操作成功响应结果(带响应数据)
    public static <E> Wangeditor<E> success(E data) {
        return new Wangeditor<>(0, "操作成功", data);
    }
    public static Wangeditor suc(Object data, Long total) {
        return new Wangeditor<>(0, "成功", data);
    }
    //快速返回操作成功响应结果
    public static Wangeditor success() {
        return new Wangeditor(0, "操作成功", null);
    }

    public static Wangeditor error(String message) {
        return new Wangeditor(1, message, null);
    }
}
